version: '3.0'
services:

  db:
    image: postgres:12.4
    restart: always
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.env

  backend:
    image: ebudaev/foodgram:v1
    container_name: foodgram
    restart: always
    volumes:
      - static_value:/code/static/
      - media_value:/code/media/
    depends_on:
      - db
    env_file:
      - ./.env

  frontend:
    image: ebudaev/foodgram_frontend:v1
    container_name: foodgram_frontend
    volumes:
      - ../frontend/:/app/result_build/
    depends_on:
      - backend

  nginx:
    image: nginx:1.19.3
    ports:
      - 80:80
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ../frontend/build:/usr/share/nginx/html/
      - ../docs/redoc.html:/usr/share/nginx/html/api/docs/redoc.html
      - ../docs/openapi-schema.yml:/usr/share/nginx/html/api/docs/openapi-schema.yml
      - static_value:/var/html/static/
      - media_value:/var/html/media/
    restart: always
    depends_on:
      - frontend
      - backend

volumes:
  postgres_data:
  static_value:
  media_value:
